# Makefile for GNU CVS program.
# Do not use this makefile directly, but only from `../Makefile'.
# Copyright (C) 1986, 1988-1990 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

# $CVSid: @(#)Makefile.in 1.19 94/09/29 $

SHELL = /bin/sh

srcdir     = @srcdir@
top_srcdir = @top_srcdir@
VPATH      = @srcdir@

prefix = @prefix@
exec_prefix = @exec_prefix@

# Where to install the executables.
bindir = $(exec_prefix)/bin

# Where to put the system-wide .cvsrc file
libdir = $(prefix)/lib

# Where to put the manual pages.
mandir = $(prefix)/man

# Use cp if you don't have install.
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@

LIBS = @LIBS@

SOURCES = add.c admin.c checkin.c checkout.c classify.c client.c commit.c \
create_adm.c cvsrc.c diff.c edit.c entries.c error.c expand_path.c \
fileattr.c find_names.c hash.c history.c ignore.c import.c \
lock.c log.c login.c logmsg.c main.c mkmodules.c modules.c myndbm.c no_diff.c \
parseinfo.c patch.c rcs.c rcscmds.c recurse.c release.c remove.c repos.c \
root.c rtag.c scramble.c server.c status.c subr.c filesubr.c run.c \
tag.c update.c watch.c wrapper.c vers_ts.c version.c

OBJECTS = add.o admin.o checkin.o checkout.o classify.o client.o commit.o \
create_adm.o cvsrc.o diff.o edit.o entries.o expand_path.o \
fileattr.o find_names.o hash.o history.o ignore.o import.o \
lock.o log.o login.o logmsg.o main.o mkmodules.o modules.o myndbm.o no_diff.o \
parseinfo.o patch.o rcs.o rcscmds.o recurse.o release.o remove.o repos.o \
root.o rtag.o scramble.o server.o status.o tag.o update.o \
watch.o wrapper.o vers_ts.o \
subr.o filesubr.o run.o version.o error.o

HEADERS = cvs.h rcs.h hash.h myndbm.h \
	update.h server.h client.h error.h fileattr.h edit.h watch.h

TAGFILES = $(HEADERS) options.h.in $(SOURCES)

DISTFILES = .cvsignore Makefile.in ChangeLog ChangeLog-9395 ChangeLog-9194 \
	    NOTES README-rm-add \
            sanity.sh cvsbug.sh $(TAGFILES)

PROGS = cvs cvsbug

DEFS = @DEFS@ @includeopt@

CC	 = @CC@
CFLAGS = @CFLAGS@
CPPFLAGS =
LDFLAGS = @LDFLAGS@

INCLUDES = -I. -I.. -I$(srcdir) -I$(top_srcdir)/lib
.c.o:
	$(CC) $(CPPFLAGS) $(INCLUDES) $(DEFS) $(CFLAGS) -c $<

all: Makefile $(PROGS)
.PHONY: all

saber_cvs:
	@cd ..; $(MAKE) saber SUBDIRS=src

lint:
	@cd ..; $(MAKE) lint SUBDIRS=src

# CYGNUS LOCAL: Do not depend upon installdirs
install:
	@for prog in $(PROGS); do \
	  echo Installing $$prog in $(bindir); \
	  $(INSTALL) $$prog $(bindir)/$$prog ; \
	done

installdirs:
	$(SHELL) $(top_srcdir)/mkinstalldirs $(bindir)

.PHONY: install installdirs

installcheck:
	RCSBIN=$(bindir) ; export RCSBIN ; $(SHELL) $(srcdir)/sanity.sh $(bindir)/cvs
.PHONY: installcheck

check: all
	if [ -x ../../rcs/src/rcs ] ; then \
		RCSBIN=`pwd`/../../rcs/src ; \
		export RCSBIN ; \
	fi ; \
	$(SHELL) $(srcdir)/sanity.sh `pwd`/cvs
.PHONY: check

# I'm not sure there is any remaining reason for this to be separate from
# `make check'.
remotecheck: all
	$(SHELL) $(srcdir)/sanity.sh -r `pwd`/cvs
.PHONY: remotecheck

tags: $(TAGFILES)
	ctags $(TAGFILES)

TAGS: $(TAGFILES)
	etags `for i in $(TAGFILES); do echo $(srcdir)/$$i; done`

ls:
	@echo $(DISTFILES)
.PHONY: ls

clean:
	/bin/rm -f $(PROGS) *.o core check.log check.plog
.PHONY: clean

distclean: clean
	rm -f tags TAGS Makefile options.h
.PHONY: distclean

realclean: distclean
.PHONY: realclean

dist-dir:
	mkdir ${DISTDIR}
	for i in ${DISTFILES}; do \
	  ln $(srcdir)/$${i} ${DISTDIR}; \
	done
.PHONY: dist-dir

# Linking rules.

$(PROGS): ../lib/libcvs.a

cvs: $(OBJECTS)
	$(CC) $(OBJECTS) ../lib/libcvs.a $(LIBS) $(LDFLAGS) -o $@ 

xlint: $(SOURCES)
	files= ; \
	for i in $(SOURCES) ; do \
	  files="$$files $(srcdir)/$$i" ; \
	done ; \
	sh -c "lint $(DEFS) $(INCLUDES) $$files | grep -v \"possible pointer alignment problem\" \
	| grep -v \"argument closure unused\""

saber: $(SOURCES)
	# load $(CFLAGS) $(SOURCES)
	# load ../lib/libcvs.a $(LIBS)

cvsbug: cvsbug.sh
	echo > .fname \
	  cvs-`sed < $(srcdir)/version.c \
		    -e '/version_string/!d' \
		    -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \
		    -e q`
	sed -e 's,xLIBDIRx,$(libdir)/cvs,g' \
	    -e "s,xVERSIONx,`cat .fname`,g" $(srcdir)/$@.sh > $@-t
	rm -f .fname
	mv $@-t $@
	chmod a+x $@

# Compilation rules.

$(OBJECTS): $(HEADERS) options.h

subdir = src
Makefile: ../config.status Makefile.in
	cd .. && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status

options.h: ../config.status options.h.in
	cd .. && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= ./config.status

#../config.status: ../configure
#	cd .. ; $(SHELL) config.status --recheck

#../configure: ../configure.in
#	cd $(top_srcdir) ; autoconf
